﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta name="viewport" content="width=device-width" />
    <title>模块信息</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <link href="../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../lib/layui/layui.js"></script>

    <script type="text/javascript" src="../lib/Base64/base64.min.js"></script>
    <script type="text/javascript" src="../linq.js/linq.js"></script>
    <script src="../lib/cookie/cookie.js"></script>
    <style>
        .undisplay {
            display:none;
        }
    </style>
</head>
<body>
    <div class="layui-card-body" style="">
        <form class="layui-form" name="newProcessF" lay-filter="newProcessF">
            <div class="layui-form-item">
                <label class="layui-form-label">文 件 名:</label>
                <div class="layui-input-block">
                    <input type="text" name="fileName" lay-verify="title" autocomplete="off" required="required" value="" placeholder="(必填)请输入文件名" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item undisplay" id="mlflagItem">
                <label class="layui-form-label">机器学习:</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="MLFlag" lay-skin="switch" lay-text="启用|关闭" value="1">
                </div>
            </div>
            <div class="layui-form-item undisplay" id="typeItem">
                <label class="layui-form-label" style="width:90px; padding-left:5px;">切分模式提取:</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="type" lay-skin="switch" lay-text="启用|关闭"  value="1">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注信息:</label>
                <div class="layui-input-block">
                    <input type="text" name="explain" lay-verify="title" autocomplete="off" value="" placeholder="备注信息" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="savefile">立即提交</button>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        function getrequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        };
        layui.use('form', function () {
            var form = layui.form;
            var dir = JSON.parse(window.decodeURIComponent(atob(getrequest().dir)));
            if (dir.indexOf("2docsubsection") > -1) {
                layui.$("#mlflagItem").removeClass("undisplay");
                layui.$("#typeItem").removeClass("undisplay");
            }
            form.render();
            
            //监听提交
            form.on('submit(savefile)', function (data) {
                layui.$.ajax({
                    cache: false,
                    type: "post",
                    url: localStorage.getItem('hosttingaddr') + '/api/MoudleCfgFile/saveFile?dir=' + dir,
                    headers: {
                        user: getCookie("userinfo"),
                        version: getCookie("version")
                    },
                    dataType:'json',
/*                    contentType:'application/json',*/
                    /*data: JSON.stringify(data.field),*/
                    data: data.field,
                    success: function (data) {
                        if (data == "success") {
                            layer.msg('保存完成!', { icon: 1, time: 1000 });
                            parent.layui.table.reload('tablemoudle_id');
                            var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                            parent.layer.close(index);
                        } else {
                            layer.msg('发生错误:', { icon: 1, time: 3000 });
                        }
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        if (jqXHR.responseText == "success") {
                            layer.msg('保存完成!', { icon: 1, time: 1000 });
                            parent.layui.table.reload('tablemoudle_id');
                            var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                            parent.layer.close(index);
                        } else {
                            layer.msg('发生错误:' + jqXHR.responseText, { icon: 1, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>